import os

# 定义需要移除的多个字符串
remove_strings = ["📢", "💗", "💕","⭐","💢","👠","❤️","🥵","🔊","🎧"]  # 在这里添加你想要移除的字符串

# 获取G:\iwara目录下的所有文件夹名，并去除文件名中的指定字符
iwara_path = r"G:\iwara"

# 检查路径是否存在
if os.path.exists(iwara_path):
    # 遍历目录中的所有项目
    for item in os.listdir(iwara_path):
        item_path = os.path.join(iwara_path, item)
        print(item_path)
        # 只处理文件夹且文件名包含任何需要移除的字符串
        if os.path.isfile(item_path) and any(rs in item for rs in remove_strings):
            print("存在需要修改的字符")
            # 去除文件名中所有需要移除的字符串
            new_name = item
            for rs in remove_strings:
                new_name = new_name.replace(rs, "")
            new_path = os.path.join(iwara_path, new_name)

            # 重命名文件夹
            try:
                os.rename(item_path, new_path)
                print(f"已重命名: {item} -> {new_name}")
            except Exception as e:
                print(f"重命名失败 {item}: {e}")

# 存储处理后的文件夹名列表
folder_names = []
for item in os.listdir(iwara_path):
    item_path = os.path.join(iwara_path, item)
    if os.path.isdir(item_path):
        folder_names.append(item)
